//
//  hotDiscussImageTableViewCell.m
//  LT
//
//  Created by dllo on 16/5/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "hotDiscussImageTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation hotDiscussImageTableViewCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
    
}

-(void)createSubViews{
    
    //    photoImage
    //    authorLabel
    //    titleLabel;
    //    countryLabel;
    //    reply_timeLabel;
    //    reply_numLabel;
    
    self.authorLabel = [[UILabel alloc]init];
   // self.authorLabel.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.authorLabel];
    
    self.titleLabel = [[UILabel alloc]init];
//    self.titleLabel.backgroundColor = [UIColor whiteColor];
    self.titleLabel.numberOfLines = 2;
    [self.contentView addSubview:self.titleLabel];
    
    self.countryLabel = [[UILabel alloc]init];
  //  self.countryLabel.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.countryLabel];
    
    self.reply_timeLabel = [[UILabel alloc]init];
  //  self.reply_timeLabel.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.reply_timeLabel];
    
    self.reply_numLabel = [[UILabel alloc]init];
 //   self.reply_numLabel.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.reply_numLabel];
    
    self.image1 = [[UIImageView alloc]init];
 //   self.image1.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.image1];
    
    self.image2 = [[UIImageView alloc]init];
 //   self.image2.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.image2];
    
    self.image3 = [[UIImageView alloc]init];
//    self.image3.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.image3];
    
    self.avatar = [[UIImageView alloc]init];
 //   self.avatar.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.avatar];
}



-(void)layoutSubviews{
    [super layoutSubviews];
    self.avatar.frame = CGRectMake(20* WIDTHCELL, 20* WIDTHCELL, 40* WIDTHCELL, 40* WIDTHCELL);

    self.authorLabel.frame = CGRectMake(80* WIDTHCELL, 25* WIDTHCELL, 100* WIDTHCELL, 20* WIDTHCELL);
    self.titleLabel.frame = CGRectMake(30, 60, (self.contentView.frame.size.width - 50)* WIDTHCELL, 50* WIDTHCELL);
    self.image1.frame = CGRectMake(30* WIDTHCELL, 120* WIDTHCELL, 110* WIDTHCELL, 110* WIDTHCELL);
    self.image2.frame = CGRectMake(160* WIDTHCELL, 120* WIDTHCELL, 110* WIDTHCELL, 110* WIDTHCELL);
    self.image3.frame = CGRectMake(290* WIDTHCELL, 120* WIDTHCELL, 110* WIDTHCELL, 110* WIDTHCELL);
    self.countryLabel.frame = CGRectMake(50* WIDTHCELL, 230* WIDTHCELL, 50* WIDTHCELL, 20* WIDTHCELL);
    self.reply_timeLabel.frame = CGRectMake(200* WIDTHCELL, 230* WIDTHCELL, 100* WIDTHCELL, 20* WIDTHCELL);
    self.reply_numLabel.frame = CGRectMake(300* WIDTHCELL, 230* WIDTHCELL, 100* WIDTHCELL, 20* WIDTHCELL);
    
}

-(void)setModel:(hotDisModel *)model{
    _model = model;
    self.authorLabel.text = _model.author;
    self.titleLabel.text = _model.title;
    self.reply_numLabel.text = [_model.reply_num stringValue];
    self.reply_timeLabel.text = _model.reply_time;
    [self.avatar sd_setImageWithURL:[NSURL URLWithString:model.avatar
                                     ]];
   // NSLog(@"%@",model.bigpic_arr[0]);
    
    switch (model.bigpic_arr.count) {
        case 1:
            [self.image1 sd_setImageWithURL:model.bigpic_arr[0]];
            [self.image2 sd_setImageWithURL:nil];
            [self.image3 sd_setImageWithURL:nil];
           
            break;
        case 2:
            [self.image1 sd_setImageWithURL:model.bigpic_arr[0]];
            [self.image2 sd_setImageWithURL:model.bigpic_arr[1]];
            [self.image3 sd_setImageWithURL:nil];
           
            break;
        case 3:
            [self.image1 sd_setImageWithURL:model.bigpic_arr[0]];
            [self.image2 sd_setImageWithURL:model.bigpic_arr[1]];
            [self.image3 sd_setImageWithURL:model.bigpic_arr[2]];
            
            break;
        default:
            break;
    }
  
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
